﻿//Copyright © Omega Point 2008
//All rights reserved.
//This Software is Licensed under the New BSD License
//for a full copy of this license see http://www.codeplex.com/networkmessenger/license
//Redistributions of source code must retain the above copyright notice.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using OmegaPoint.Vista.Dwm;

namespace NetworkMessenger
{
    /// <summary>
    /// Interaction logic for ReceivedMessageWindow.xaml
    /// </summary>
    public partial class ReceivedMessageWindow : Window
    {
        public ReceivedMessageWindow(Message receivedMessage)
        {
            InitializeComponent();
            toTextBox.Text= receivedMessage.To;
            fromTextBox.Text = receivedMessage.From;
            timestampTextBox.Text = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString();

            messageTextBox.Text = receivedMessage.MessageBody;
        }

        private void closeButton_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void replyButton_Click(object sender, RoutedEventArgs e)
        {
            SendMessageWindow replyWindow = new SendMessageWindow(fromTextBox.Text);
            replyWindow.ShowDialog();
            replyWindow = null;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (Aero.DoesOSSupportDwm() == true)
            {
                try
                {
                    Aero.ExtendGlassFrame(this, new Thickness(-1));
                }
                catch (Exception)
                {
                    //Alter Background to fill area
                    backgroundRectangle.RadiusX = 0;
                    backgroundRectangle.RadiusY = 0;
                    backgroundRectangle.Opacity = 1;
                }
            }
            else
            {
                backgroundRectangle.RadiusX = 0;
                backgroundRectangle.RadiusY = 0;
                backgroundRectangle.Opacity = 1;
            }        
        }
    }
}
